package com.cat.model.memcache;

import com.alonew.memcache.MemCacheFactory;
import com.alonew.memcache.MemCacheManager;
import com.alonew.memcache.util.MemInfo;
import com.alonew.memcache.util.MemLogic;

public class MemFactory {

	private static MemLogic<SpringdemoMemKey> springdemo = new MemLogic<SpringdemoMemKey>() {

		@Override
		public void afterDelete(String paramString) {

		}

		@Override
		public MemCacheManager getMgr() {
			return MemCacheFactory.getInstance().getManagerByIps("mem1.app.lenovomobile.com");
		}
	};

	public static MemLogic<SpringdemoMemKey> getSpringdemo() {
		return springdemo;
	}
	
	public static void main(String[] args){
		// MemInfo<ServiceMemKey> testInfo = ServiceMemKey.test.build("uid");
		// MemFactory.getService().setToCache(testInfo, "fff");
		// String aa = MemFactory.getService().getFromCache(testInfo);
		// System.out.println("获取:" + aa);
		//TODO 模拟登陆时候存储的sessionkey
		MemInfo<SpringdemoMemKey> sessionKey = SpringdemoMemKey.test.build("0");
		System.out.println(sessionKey.getRealKey());
//		String uuidStr = UUID.randomUUID().toString() + "_15860785875_0";
		String uuidStr = "test_15860785875_0";
		MemFactory.getSpringdemo().setToCache(sessionKey, uuidStr);
		String result = MemFactory.getSpringdemo().getFromCache(sessionKey);
		System.out.println(result);
	}
}
